/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mygame;

import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.PhysicsTickListener;
import com.jme3.bullet.collision.shapes.CylinderCollisionShape;
import com.jme3.bullet.control.GhostControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.objects.PhysicsRigidBody;
import com.jme3.math.FastMath;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;

/**
 *
 * @author Peter
 */
public class BasicTower extends Tower {

    private float range = 2.0f;
    private AttType attType = AttType.ATTBASIC;
    protected float x,y,z;
     protected float t = 0f;
     public Spatial tower2;
     protected GhostControl towerRangeControl;
    
    BasicTower(Vector3f coords, Float scale, Main main){
        //super();
        mainApp  = main; 
        //app.getStateManager().attach(this);
        //super.initialize(mainApp.getStateManager(), app);
        
        //this.setEnabled(true);

        tower2 = mainApp.getAssetManager().loadModel("Models/veza/tower.j3o");
        
         tower2.setLocalTranslation(coords.x, coords.y, coords.z);
         tower2.scale(scale, scale, scale);
         CylinderCollisionShape rangeShape;
        rangeShape = new CylinderCollisionShape(new Vector3f(range, range, range),1);
        towerRangeControl = new GhostControl( rangeShape);
    
        //towerRangeControl.setApplyPhysicsLocal(true);
        //towerRangeControl.setPhysicsLocation(new Vector3f(0f, 100.0f, 0f));
        
        tower2.addControl(towerRangeControl);
        
        main.getStateManager().getState(BulletAppState.class).getPhysicsSpace().add(towerRangeControl);
       //rangeShape.(new Vector3f(10.0f, 5.0f, 0.0f));
        mainApp.getRootNode().attachChild(tower2);
        //tower2.getControl(GhostControl.class).setPhysicsLocation(new Vector3f(0f, -1, 0f));
         
        
        
    }
    
        
    @Override
    public void update(float tpf) {
            System.out.println("Vypis3 " + tower2.getControl(GhostControl.class).getOverlappingObjects());
        System.out.println("Vypis4 " + tower2.getControl(GhostControl.class).getOverlappingCount());
        //super.update(tpf);
            //if (tower1 == null )
                
       //System.out.println("HAHAHAHAHAHAHA");
            //if (t < 2 && tower2.getLocalTranslation().y > 0 && t != 0) 
       
        
    }

 
    
}
